﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Data;


namespace KD.DataImport
{
    class UploadMain
    {
        /// <summary>
        /// 本类的唯一实例
        /// </summary>
        private static UploadMain OWNER = null;

        /// <summary>
        /// 
        /// </summary>
        private static string _strErrInfo = string.Empty, _strErrCode = string.Empty;

        /// <summary>
        /// 私有构造函数
        /// </summary>
        private UploadMain()
        {
            DAS.Component.Data.DataHelper.DoInit();
        }

        /// <summary>
        /// 获取类的唯一实例
        /// </summary>
        /// <returns></returns>
        public static UploadMain Instance
        {
            get
            {
                if (UploadMain.OWNER == null)
                {
                    UploadMain.OWNER = new UploadMain();
                }
                return UploadMain.OWNER;
            }
        }

        /// <summary>
        /// 
        /// </summary>
        /// <param name="lpr"></param>
        /// <param name="flowid"></param>
        /// <param name="tlen"></param>
        /// <param name="twidth"></param>
        /// <param name="len"></param>
        /// <param name="width"></param>
        /// <param name="height"></param>
        /// <param name="postion"></param>
        /// <param name="date"></param>
        /// <param name="mine"></param>
        /// <param name="material"></param>
        /// <param name="supplier"></param>
        /// <param name="transport"></param>
        /// <param name="machine"></param>
        /// <param name="pail"></param>
        /// <param name="poscount"></param>
        /// <param name="layout"></param>
        /// <param name="begintime"></param>
        /// <param name="endtime"></param>
        /// <param name="state"></param>
        /// <param name="weight"></param>
        /// <param name="rfid"></param>
        /// <param name="pos"></param>
        /// <param name="DasUser"></param>
        /// <param name="DasPassword"></param>
        /// <returns></returns>
        public RequestResult DoUploadSamplingInfo(string lpr, string flowid, decimal tlen, decimal twidth, decimal len, decimal width, decimal height, string postion
           , string date, string mine, string material, string supplier, string transport
            , string machine, int pail, int poscount, int layout, string begintime, string endtime, int state, decimal weight, string rfid, string pos, string imgbegin, string imgend
            , string DasUser, string DasPassword)
        {
            RequestResult model = new RequestResult();
            Titan.DAS.Msg.Common.ProcParam[] _parms = new Titan.DAS.Msg.Common.ProcParam[]{
                                               new Titan.DAS.Msg.Common.ProcParam{Name = "P_LPR",Value = lpr,Direction = ParameterDirection.Input,DbType = Convert.ToInt32(Titan.DAS.Client.Data.ODB_Type.NVarchar2),Size=200},
                                               new Titan.DAS.Msg.Common.ProcParam{Name = "P_PRIMARYKEY",Value = flowid,Direction = ParameterDirection.Input,DbType = Convert.ToInt32(Titan.DAS.Client.Data.ODB_Type.NVarchar2),Size=200},
                                               new Titan.DAS.Msg.Common.ProcParam{Name = "P_TOTLE_LENGTH",Value =tlen,Direction = ParameterDirection.Input,DbType = Convert.ToInt32(Titan.DAS.Client.Data.ODB_Type.Decimal)},
                                               new Titan.DAS.Msg.Common.ProcParam{Name = "P_TOTLE_WIDTH",Value =twidth,Direction = ParameterDirection.Input,DbType = Convert.ToInt32(Titan.DAS.Client.Data.ODB_Type.Decimal)},
                                               new Titan.DAS.Msg.Common.ProcParam{Name = "P_LENGTH",Value =len,Direction = ParameterDirection.Input,DbType = Convert.ToInt32(Titan.DAS.Client.Data.ODB_Type.Decimal)},
                                               new Titan.DAS.Msg.Common.ProcParam{Name = "P_WIDTH",Value =width,Direction = ParameterDirection.Input,DbType = Convert.ToInt32(Titan.DAS.Client.Data.ODB_Type.Decimal)},
                                               new Titan.DAS.Msg.Common.ProcParam{Name = "P_HEIGHT",Value =height,Direction = ParameterDirection.Input,DbType = Convert.ToInt32(Titan.DAS.Client.Data.ODB_Type.Decimal)},
                                               new Titan.DAS.Msg.Common.ProcParam{Name = "P_POSTIONS",Value = postion,Direction = ParameterDirection.Input,DbType = Convert.ToInt32(Titan.DAS.Client.Data.ODB_Type.NVarchar2),Size=200},
                                               new Titan.DAS.Msg.Common.ProcParam{Name = "P_DATE",Value =date,Direction = ParameterDirection.Input,DbType = Convert.ToInt32( Titan.DAS.Client.Data.ODB_Type.NVarchar2),Size=40},
                                               new Titan.DAS.Msg.Common.ProcParam{Name = "P_MINE",Value =mine,Direction = ParameterDirection.Input,DbType = Convert.ToInt32( Titan.DAS.Client.Data.ODB_Type.NVarchar2),Size=128},
                                               new Titan.DAS.Msg.Common.ProcParam{Name = "P_MATERIEL",Value =material,Direction = ParameterDirection.Input,DbType = Convert.ToInt32( Titan.DAS.Client.Data.ODB_Type.NVarchar2),Size=128},
                                               new Titan.DAS.Msg.Common.ProcParam{Name = "P_SUPPLIER",Value =supplier,Direction = ParameterDirection.Input,DbType = Convert.ToInt32( Titan.DAS.Client.Data.ODB_Type.NVarchar2),Size=128},
                                               new Titan.DAS.Msg.Common.ProcParam{Name = "P_TRANSPORT",Value =transport,Direction = ParameterDirection.Input,DbType = Convert.ToInt32( Titan.DAS.Client.Data.ODB_Type.NVarchar2),Size=128},
                                               new Titan.DAS.Msg.Common.ProcParam{Name = "P_MECHINE",Value = machine,Direction = ParameterDirection.Input,DbType = Convert.ToInt32(Titan.DAS.Client.Data.ODB_Type.NVarchar2),Size=40},
                                               new Titan.DAS.Msg.Common.ProcParam{Name = "P_PAIL",Value =pail,Direction = ParameterDirection.Input,DbType = Convert.ToInt32(Titan.DAS.Client.Data.ODB_Type.Decimal)},
                                               new Titan.DAS.Msg.Common.ProcParam{Name = "P_POSCOUNT",Value =poscount,Direction = ParameterDirection.Input,DbType = Convert.ToInt32(Titan.DAS.Client.Data.ODB_Type.Decimal)},
                                               new Titan.DAS.Msg.Common.ProcParam{Name = "P_LAYOUT",Value =layout,Direction = ParameterDirection.Input,DbType = Convert.ToInt32(Titan.DAS.Client.Data.ODB_Type.Decimal)},
                                               new Titan.DAS.Msg.Common.ProcParam{Name = "P_BEGINTIME",Value =begintime,Direction = ParameterDirection.Input,DbType = Convert.ToInt32( Titan.DAS.Client.Data.ODB_Type.NVarchar2),Size=40},
                                               new Titan.DAS.Msg.Common.ProcParam{Name = "P_ENDTIME",Value =endtime,Direction = ParameterDirection.Input,DbType = Convert.ToInt32( Titan.DAS.Client.Data.ODB_Type.NVarchar2),Size=40},
                                               new Titan.DAS.Msg.Common.ProcParam{Name = "P_STATE",Value =state,Direction = ParameterDirection.Input,DbType = Convert.ToInt32(Titan.DAS.Client.Data.ODB_Type.Decimal)},
                                               new Titan.DAS.Msg.Common.ProcParam{Name = "P_WEIGHT",Value =weight,Direction = ParameterDirection.Input,DbType = Convert.ToInt32(Titan.DAS.Client.Data.ODB_Type.Decimal)},
                                               new Titan.DAS.Msg.Common.ProcParam{Name = "P_RDIF",Value =rfid,Direction = ParameterDirection.Input,DbType = Convert.ToInt32( Titan.DAS.Client.Data.ODB_Type.NVarchar2),Size=128},
                                               new Titan.DAS.Msg.Common.ProcParam{Name = "P_POS",Value =pos,Direction = ParameterDirection.Input,DbType = Convert.ToInt32( Titan.DAS.Client.Data.ODB_Type.NVarchar2),Size=128},
                                               new Titan.DAS.Msg.Common.ProcParam{Name = "P_POS",Value =imgbegin,Direction = ParameterDirection.Input,DbType = Convert.ToInt32( Titan.DAS.Client.Data.ODB_Type.Clob)},
                                               new Titan.DAS.Msg.Common.ProcParam{Name = "P_POS",Value =imgend,Direction = ParameterDirection.Input,DbType = Convert.ToInt32( Titan.DAS.Client.Data.ODB_Type.Clob)}};

            KD.DAS.Component.Data.EntityExecProc _modelProc = KD.DAS.Component.Data.DataHelper.ExecProc(DasUser, DasPassword, "PCK_INTERFACE_WL.DO_SYNC_CAR_LOGISTICS", _parms);
            if (!_modelProc.RSuccess || _modelProc.RStatuCode != 1)
            {
                model.En_ErrCode = _modelProc.RStatuCode.ToString();
                model.En_ErrInfo = _modelProc.RStatuDesc;
            }
            else
                model.En_Success = true;
            return model;
        }
    }
}
